package com.dems.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dems.dao.StudentDao;
import com.dems.domain.Student;


@WebServlet("/RegistStudentServlet")
public class RegistStudentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private StudentDao registStudentDao = new StudentDao();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistStudentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取参数
		String account = request.getParameter("account");
		String password = request.getParameter("password");
		String buildingId = request.getParameter("buildingId");
		Student student = new Student();
		student.setStudentNum(account);
		student.setStudentPassword(password);
		student.setBuildingId(buildingId);
		registStudentDao.registStudent(student);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
